home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
pluginy Firefox
/
1833
/
1833.xpi
/
chrome
/
yoono.jar
/
content
/
yoono
/
dialogs
/
changepasswd.js
next >
Wrap
Text File
|
2009-12-16
|
3KB
|
91 lines
const MAXLENGTH = 50;
const MINLENGTH = 6;
const DIALOG = document.getElementById('yoono-dialog-changepasswd');
const PASSWDXTBOX = document.getElementById('yoono-changepasswd-newpasswd-textbox');
const CONFIRMTXTBOX = document.getElementById('yoono-changepasswd-confirm-newpasswd-textbox');
const CURRENTTXTBOX = document.getElementById('yoono-changepasswd-currentlogin-textbox');
const PASSNOMATCHWARN = document.getElementById('yoono-changepasswd-newpasswd-notmatch');
const PASSINVALIDWARN = document.getElementById('yoono-changepasswd-newpasswd-invalid');
const SUCCESSWARN = document.getElementById('yoono-changepasswd-success');
const CONNECTERROR = document.getElementById('yoono-changepasswd-connecterror');
const IDPASSSTR = YNPREFBRANCH.getCharPref('userid');
const ID = IDPASSSTR.slice(0, IDPASSSTR.indexOf(':'));
var serverUrl = YNPREFBRANCH.getCharPref('serverurl');
function init() {
CURRENTTXTBOX.value = ID;
PASSWDXTBOX.focus();
centerWindow();
}
function validateForm() {
var input = new inputFields( PASSWDXTBOX,
CONFIRMTXTBOX
);
// on reinitialise les messages d erreur
clearWarnings();
var error = false;
if (input.passwd != input.passwdConfirm) {
PASSNOMATCHWARN.hidden = false;
error = true;
} else if (!validateLoginInput(input.passwd)) {
PASSINVALIDWARN.hidden = false;
error = true;
}
if (error) {
PASSWDXTBOX.value = '';
CONFIRMTXTBOX.value = '';
PASSWDXTBOX.focus();
sizeToContent();
return false;
} else {
var script = <server-script version="1.0"/>;
script.appendChild( <context> <user-id> {IDPASSSTR} </user-id> </context>);;
script.appendChild( <change-login-password login={ID} password={input.passwd}/>);
// results is an array with request and xml result if successfull
var results = YOONO_CMPT.sendRequest(serverUrl + 'linkserver', 'POST', 'sync', script, null);
if ('' == results[1]) {
CONNECTERROR.hidden = false;
sizeToContent();
return false;
}
if (results[1]['display-message'].@code == 'MSG_LOGIN_PASSWORD_CHANGED') {
try {
SUCCESSWARN.hidden = false;
clearWarnings();
disableTextBoxes();
sizeToContent();
YOONO_CMPT.registerUser(ID, input.passwd);
YOONO_CMPT._globalService.accountsManager.onPostLoginInit(
YOONO_CMPT._globalService.accountsManager.YOONO_USER_CHANGED_PWD,
YOONO_CMPT.getUserCredential()
);
var pc = YNPREFBRANCH.getIntPref('pwd.changes');
YNPREFBRANCH.setIntPref('pwd.changes', pc + 1);
validateForm = function () {};
DIALOG.buttons="accept";
} catch(e) {
return false;
}
}
return false;
}
}
function inputFields(passwdField, passwdConfirmField) {
this.passwd = passwdField.value;
this.passwdConfirm = passwdConfirmField.value;
}